package com.woniuxy.death.listener;

import com.rabbitmq.client.Channel;
import com.woniuxy.po.Mail;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Author: 马宇航
 * @Description: 正常消费者不开发了，只开发死信消费者
 * @DateTime: 22/12/29/0029 17:49
 * @Component: 成都蜗牛学苑
 **/
@Component
@RabbitListener(queues = "deathQueue")
public class DeathConsumer {
    @RabbitHandler
    public void deadLetterProcessing(Mail mail, Channel channel, Message message) throws IOException {
        System.out.println("通知开发回来改bug，正常队列无法处理数据："+mail);
        channel.basicQos(1);//这个可以设置为，每次处理一个消息
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }

}
